﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using MvcAtletIS.Models;

namespace MvcAtletIS.Controllers
{
    public class ContactsController : Controller
    {
        private atletisEntities db = new atletisEntities();
        
        // GET: /Contacts/
        public ActionResult Index(int CategoryId = 1)
        {
            ViewBag.CategoryId = new SelectList(db.WebcontactsCategories.Where(dc => dc.Active == true).OrderBy(dc => dc.Order).ToList(), "ID", "Name", CategoryId);
            var model = db.Webcontacts.Include("WebcontactsCategories").Where(wc => wc.CategoryId == CategoryId & wc.Active == true).OrderBy(wc => wc.Order).ThenBy(wc => wc.Surname).ToList();
            return View(model);
        }

        // GET: /Contacts/Detail/5
        public ActionResult Detail(int id)
        {
            var model = db.Webcontacts.SingleOrDefault(w => w.ID == id);
            if (model == null)
            {
                return HttpNotFound();
            }
            return View(model);
        }



    }
}
